<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [1, 3, 5, 7, 9, 10];
      function getAvg(array) {
        let sum = 0;
        let item = 0;
        for (let index = 0; index < array.length; index++) {
          const element = array[index];
          if (element % 2 !== 0) {
            sum += element;
            item++;
          }
        }
        if (item === 0) {
          return item;
        } else {
          return sum / item;
        }
      }
      console.log(getAvg(arr));
    </script>
  </body>
</html>
